#ifndef _DLLIST_H_
#define _DLLIST_H_
#include <stdio.h>
#include <stdlib.h>

#include "declare.h"

#define ELEMTYPE int

struct DLNode;

typedef struct DLNode * PNode;
typedef struct DLNode * POSITION;

struct DLNode {
    ELEMTYPE info;
    PNode left;
    PNode right;
};

struct dlList {
    PNode head;
    PNode rear;
    SIZE_T length;
};

typedef struct dlList * DLList;
DLList createDLList(void);
int insertPostDLList(DLList list, POSITION p, ELEMTYPE x);
int insertPreDLList(DLList list, POSITION p, ELEMTYPE x);
int deleteElemDLList(DLList list, ELEMTYPE x);
int deleteVertexDLList(DLList list, POSITION p);
POSITION locateVertexDLList(DLList list, ELEMTYPE x);
void printDLList(DLList list);
void destroyDLList(DLList *list);
int appendElemDLList(DLList list, ELEMTYPE x);
SIZE_T lengthDLList(DLList list);
POSITION getPositionByIndexDLList(DLList list, SIZE_T index);
#endif
